package com.lzq.treefold;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import com.zaxxer.hikari.HikariDataSource;

import org.springframework.boot.test.context.SpringBootTest;

import java.nio.file.Paths;

@SpringBootTest
public class CodeGenerator {

    @Resource
    HikariDataSource dataSource;


    @Test
    void Generate() {
        FastAutoGenerator.create(dataSource.getJdbcUrl(), dataSource.getUsername(), dataSource.getPassword())
                .globalConfig(builder -> builder
                        .author("Lzq")
                        .outputDir("D:\\Projects\\IDEA\\tree-fold\\src\\main\\java")
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent("com.lzq.treefold")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        .entityBuilder()
                        .enableLombok()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
